/**
 * 
 */
package net.sf.rose.common;

import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * @author user
 * 
 */
public class RunException extends RuntimeException {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6882152456479491706L;

	private List<String> list = new ArrayList<String>();

	/**
	 * @param message
	 */
	public RunException() {
		super();
	}

	/**
	 * @param cause
	 */
	public RunException(Throwable cause) {
		super(cause);
	}

	/**
	 * 
	 */
	public void printStackTrace(PrintStream s) {
		synchronized (s) {
			for (String str : list) {
				s.println(str);
			}
		}
		super.printStackTrace(s);
	}

	/**
	 * 
	 */
	public void printStackTrace(PrintWriter s) {
		synchronized (s) {
			for (String str : list) {
				s.println(str);
			}
		}
		super.printStackTrace(s);
	}

	/**
	 * 
	 */
	public void putMessage(String message) {
		list.add(message);
	}

	/**
	 * 
	 */
	public String getMessage() {
		if (list.size() == 0) {
			return super.getMessage();
		}
		return list.get(0);
	}
}
